package com.linkivr.model;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

@Entity
public class T_channel {
	private int id;				//编号
	private int chn_id;			//通道编号
	private String chn_name;	//通道名称
	private Date updateTime;	//更新时间
	private double lastData;	//最新数据
	private String chn_state;		//通道状态
	private T_module module;			//模块编号
	private T_factor factor;			//因子编号
	private boolean use_function;	//是否使用二次函数
	private	T_function function;			//二次函数编号
	
	@Id
	@GeneratedValue
	public int getId(){
		return id;
	}
	public void setId(int id){
		this.id = id;
	}
	
	public int getChn_id() {
		return chn_id;
	}
	public void setChn_id(int chnId) {
		chn_id = chnId;
	}
	public String getChn_name() {
		if(chn_name==null)
			return "";
		return chn_name;
	}
	public void setChn_name(String chnName) {
		chn_name = chnName;
	}
	
	public boolean getUse_function() {
		return use_function;
	}
	public void setUse_function(boolean useFunction) {
		use_function = useFunction;
	}

	@ManyToOne(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
	@JoinColumn(name = "mod_id")
	public T_module getModule() {
		return module;
	}
	public void setModule(T_module module) {
		this.module = module;
	}
	
	@ManyToOne(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
	@JoinColumn(name = "fac_id")
	public T_factor getFactor() {
		return factor;
	}
	public void setFactor(T_factor factor) {
		this.factor = factor;
	}
	
	@ManyToOne(fetch=FetchType.EAGER,cascade=CascadeType.ALL)
	@JoinColumn(name = "fun_id")
	public T_function getFunction() {
		return function;
	}
	public void setFunction(T_function function) {
		this.function = function;
	}
	public Date getUpdateTime() {
		return updateTime;
	}
	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}
	public double getLastData() {
		return lastData;
	}
	public void setLastData(double lastData) {
		this.lastData = lastData;
	}
	public String getChn_state() {
		return chn_state;
	}
	public void setChn_state(String chnState) {
		chn_state = chnState;
	}

}
